<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: green;
        }
    </style>
</head>

<body>
    <div class="box">
        div1
    </div>
    <script>
        var box = document.getElementsByClassName('box')[0];
        box.onclick = function () {
            box.style.color = 'red';
            box.style.backgroundColor = 'pink'
        }
    </script>
</body>
</html>